package com.ruoyi.web.controller.production.greenhousefilm;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.greenhousefilm.GreenhousefilmPurchase;
import com.ruoyi.production.service.greenhousefilm.IGreenhousefilmPurchaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 棚膜购买信息Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/greenhousefilmPurchase")
@Api(value = "棚膜购买",tags = "棚膜购买相关API")
public class GreenhousefilmPurchaseController extends BaseController
{
    @Autowired
    private IGreenhousefilmPurchaseService greenhousefilmPurchaseService;

    /**
     * 查询棚膜购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:list')")
    @GetMapping("/list")
    @ApiOperation("查询棚膜购买表信息")
    @ApiImplicitParam(name = "greenhousefilmPurchase",value = "棚膜购买实体类",paramType = "body", dataType = "GreenhousefilmPurchase")
    public TableDataInfo list(GreenhousefilmPurchase greenhousefilmPurchase)
    {
        startPage();
        List<GreenhousefilmPurchase> list = greenhousefilmPurchaseService.selectGreenhousefilmPurchaseList(greenhousefilmPurchase);
        return getDataTable(list);
    }

    /**
     * 导出棚膜购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:export')")
    @Log(title = "棚膜购买信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出棚膜购买表信息")
    @ApiImplicitParam(name = "greenhousefilmPurchase",value = "棚膜购买实体类",paramType = "body", dataType = "GreenhousefilmPurchase")
    public AjaxResult export(GreenhousefilmPurchase greenhousefilmPurchase)
    {
        List<GreenhousefilmPurchase> list = greenhousefilmPurchaseService.selectGreenhousefilmPurchaseList(greenhousefilmPurchase);
        ExcelUtil<GreenhousefilmPurchase> util = new ExcelUtil<GreenhousefilmPurchase>(GreenhousefilmPurchase.class);
        return util.exportExcel(list, "棚膜购买信息数据");
    }

    /**
     * 获取棚膜购买信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:query')")
    @GetMapping(value = "/{greenhousefilmPurchaseId}")
    @ApiOperation("获取棚膜购买表单个信息")
    @ApiImplicitParam(name = "greenhousefilmPurchaseIds",value = "棚膜购买实体类主键",paramType = "path", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("greenhousefilmPurchaseId") Long greenhousefilmPurchaseId)
    {
        return AjaxResult.success(greenhousefilmPurchaseService.selectGreenhousefilmPurchaseById(greenhousefilmPurchaseId));
    }

    /**
     * 新增棚膜购买信息并更新棚膜量表
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:add')")
    @Log(title = "棚膜购买信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增棚膜购买表信息")
    @ApiImplicitParam(name = "greenhousefilmPurchase",value = "棚膜购买实体类",paramType = "body", dataType = "GreenhousefilmPurchase")
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody GreenhousefilmPurchase greenhousefilmPurchase)
    {
        return toAjax(greenhousefilmPurchaseService.insertPurchaseUpdateAmount(greenhousefilmPurchase));
    }

    /**
     * 修改棚膜购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:edit')")
    @Log(title = "棚膜购买信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改棚膜购买表信息")
    @ApiImplicitParam(name = "greenhousefilmPurchase",value = "棚膜购买实体类",paramType = "body", dataType = "GreenhousefilmPurchase")
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody GreenhousefilmPurchase greenhousefilmPurchase)
    {
        return toAjax(greenhousefilmPurchaseService.updateGreenhousefilmPurchase(greenhousefilmPurchase));
    }

    /**
     * 删除棚膜购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmPurchase:remove')")
    @Log(title = "棚膜购买信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{greenhousefilmPurchaseIds}")
    @ApiOperation("删除棚膜购买表信息")
    @ApiImplicitParam(name = "greenhousefilmPurchaseIds",value = "棚膜购买实体类主键数组",paramType = "path", dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] greenhousefilmPurchaseIds)
    {
        return toAjax(greenhousefilmPurchaseService.deleteGreenhousefilmPurchaseByIds(greenhousefilmPurchaseIds));
    }
}
